#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
struct kecheng
{
	char project[30];
	double xf;
	
};
struct kecheng ke[1000];

struct student
{
	char name[15];
	double fen[1000];
	double jd[1000];
	double avgjd;
	double avgfs;
	double sumfs;
	double sumjd;
	int k;
};
struct student stu[1000];


double jidian(double x)
{
	if( x>=95 && x<=100 )
		return 4.0;
	if( x>=90 && x<=94 )
		return 3.7;
	if( x>=87 && x<=89 )
		return 3.3;
	if( x>=83 && x<=86 )
		return 3.0;
	if( x>=80 && x<=82 )
		return 2.7;
	if( x>=77 && x<=79 )
		return 2.3;
	if( x>=73 && x<=76 )
		return 2.0;
	if( x>=70 && x<=72 )
		return 1.7;
	if( x>=68 && x<=69 )
		return 1.6;
	if( x>=66 && x<=67 )
		return 1.5;
	if( x>=64 && x<=65 )
		return 1.4;
	if( x>=62 && x<=63 )
		return 1.3;
	if( x==61 )
		return 1.2;
	if( x==60 )
		return 1;
	else
		return 0;	
}

bool cmp(student a,student b)
{
	if(a.avgjd == b.avgjd && a.avgfs != b.avgfs)
		return a.avgfs > b.avgfs;
	if(a.avgjd == b.avgjd && a.avgfs == b.avgfs)
		return	strcmp(a.name,b.name)<0;
	return a.avgjd > b.avgjd;
}


int main()
{
	int n,m,i,j=0;
	char temp ;
	double sumxf=0;
	scanf("%d%d",&n,&m);
	getchar();
	for(i=0;i<m;i++)
	{
		j=0;
		while( (temp=getchar())<'0' || temp>'9' )
		{
			ke[i].project[j++]=temp;
		}
		ke[i].project[j]='\0';
		ke[i].xf=temp-'0';
		if( (temp=getchar())=='.' )
		{
			temp=getchar();
			ke[i].xf+=0.1*(temp-'0');
			
		}
		else if( temp== '\n')
			continue;
	}
	for(i=0;i<m;i++)
		sumxf+=ke[i].xf;
	
	for(i=0;i<n;i++)
	{
		scanf("%s",stu[i].name);
		
		stu[i].sumfs=0;
		stu[i].sumjd=0;
		stu[i].k=0;
		
		for(j=0;j<m;j++)
		{
			scanf("%lf",&stu[i].fen[j]);
			
			
			
			if(stu[i].fen[j] < 60)
				stu[i].k++;
			stu[i].sumfs += stu[i].fen[j];
			stu[i].jd[j] = jidian( stu[i].fen[j] );
		}
		for(j=0;j<m;j++)
			stu[i].sumjd += ke[j].xf * stu[i].jd[j];
		stu[i].avgjd = stu[i].sumjd / sumxf;
		stu[i].avgfs = stu[i].sumfs / m ;
	}
	
	sort(stu,stu+n,cmp);
	
	for( i=0 ; i<n ; i++)
	{
		printf("No.%d ",i+1);
		printf("%s ",stu[i].name);
		for(j=0 ; j<m ; j++ )
			printf("%.0lf ",stu[i].fen[j]);
		printf("%.3lf ",stu[i].avgfs);
		printf("%.4lf ",stu[i].avgjd);
		printf("%d\n",stu[i].k);
	}
	return 0;
}
